﻿// ## 2023/10/31 # 墨玉丹青 # 君主不在主城和非君主城也能使用功能
// ## 2023/09/28 # 墨玉丹青 # 添加"他人妻妾图鉴","子女图鉴","他人子女图鉴
// ## 2023/09/27 # 墨玉丹青 # 添加"强娶"标签,人物身份信息 ##死亡标签单独显示,"强娶"&"怀孕"可分开显示
// ## 2023/09/26 # 墨玉丹青 # 添加"死亡""怀孕"标签,若有正妻,正妻调整到第一位
// ## 2023/09/25 # 墨玉丹青 # 基础ui界面&基础功能编写
// ## 2023/09/25 # 墨玉丹青 # 家族功能


namespace personfamily
{
    // ======================================================================

    const string shortcut_家族功能 = "";
    const array <uint> statecolor = { 0xffFFB6C1 ,0xff7B68EE, 0xffF0E68C, 0xff66CDAA , 0xff87CEEB };//五维颜色
    const array <string> zslb = { '妻','妾','图','表','子','女','图','表'};
    const array <string> 死亡 = { '死','亡' };
    const array <string> 怀孕 = { '怀','孕','未','出','生','未','出','仕','孕','育','中','已','登','场' };
    const array <string> 强娶 = { '强','娶' };
    const array <string> ww = { '统率','武力','智力','政治','魅力' };
    const array <string> 性格 = { '胆小','冷静','刚胆','莽撞' };
    const array <string> 出生地 = { '幽州','冀州','青徐','兖豫','司隶','京兆','凉州','扬州','荆北','荆南','益州','南中'};
    const array <string> 框体标题 = { '妻妾列表','子女列表','刚胆','莽撞' };
    const array <string> 嫡子类型 = { '嫡长子','嫡次子','嫡幼子','嫡季子','嫡子'};
    const array <string> 嫡女类型 = { '嫡长女','嫡次女','嫡幼女','嫡季女','嫡女'};
    const array <string> 庶女类型 = { '庶长女','庶次女','庶幼女','庶季女','庶女'};
    const array <string> 庶子类型 = { '庶长子','庶次子','庶幼子','庶季子','庶子'};

    const int qiqie_max = 21;

    // ======================================================================

    int 菜单_家族功能 = -1;

    // ======================================================================

    class Main
    {
        pk::list<pk::person@> perxiaoqie_list;
        pk::list<pk::person@> perqiqie_list;
        pk::list<pk::person@> persunzi_list;
        pk::text@ content_text;
        pk::dialog@ taishu_autonomy_dialog;
        pk::dialog@ model_dialog;
        pk::building @building_;
        pk::force @force_;
        pk::person @taishu_;
        pk::person @kunshu_;
        pk::city @city_;
        pk::gate @gate_;
        pk::port @port_;
        pk::district @district_;
        int menu_city_id_;
        int menu_force_id_;
        pk::list<pk::person@> person_list;
        pk::list<pk::person@> person_sel_arr;
        pk::person@ select_person;

        Main()
        {
            

            pk::menu_item menu_item_家族功能;
            menu_item_家族功能.menu = 0;
            menu_item_家族功能.pos = 13;
            menu_item_家族功能.shortcut = shortcut_家族功能;
            menu_item_家族功能.init = pk::building_menu_item_init_t(init_菜单_家族功能);
            menu_item_家族功能.is_visible = pk::menu_item_is_visible_t(isVisible_菜单_家族功能);
            menu_item_家族功能.is_enabled = pk::menu_item_is_enabled_t(isEnabled_菜单_家族功能);
            menu_item_家族功能.get_text = pk::menu_item_get_text_t(getText_菜单_家族功能);
            menu_item_家族功能.get_desc = pk::menu_item_get_desc_t(getDesc_菜单_家族功能);
            菜单_家族功能 = pk::add_menu_item(menu_item_家族功能);
            // ch::u8debug(pk::format("ge ren menu {}", 菜单_家族功能));

            pk::menu_item 子菜单_妻妾图鉴;
            子菜单_妻妾图鉴.menu = 菜单_家族功能;
            子菜单_妻妾图鉴.shortcut = "-";
            子菜单_妻妾图鉴.is_visible = pk::menu_item_is_visible_t(isVisible_菜单_妻妾图鉴);
            子菜单_妻妾图鉴.is_enabled = pk::menu_item_is_enabled_t(isEnabled_菜单_妻妾图鉴);
            子菜单_妻妾图鉴.get_text = pk::menu_item_get_text_t(getText_菜单_妻妾图鉴);
            子菜单_妻妾图鉴.get_desc = pk::menu_item_get_desc_t(getDesc_菜单_妻妾图鉴);
            //子菜单_妻妾图鉴.get_targets = cast<pk::unit_menu_item_get_targets_t@>(function() { return main.get_targets_arr_妻妾图鉴(); });
            子菜单_妻妾图鉴.handler = pk::menu_item_handler_t(handler_菜单_妻妾图鉴);
           // 子菜单_妻妾图鉴.handler = cast<pk::unit_menu_item_handler_t@>(function(dst_pos) { return main.handler_妻妾图鉴(dst_pos); });
            pk::add_menu_item(子菜单_妻妾图鉴);

            pk::menu_item 子菜单_子女图鉴;
            子菜单_子女图鉴.menu = 菜单_家族功能;
            子菜单_子女图鉴.shortcut = "-";
            子菜单_子女图鉴.is_visible = pk::menu_item_is_visible_t(isVisible_菜单_子女图鉴);
            子菜单_子女图鉴.is_enabled = pk::menu_item_is_enabled_t(isEnabled_菜单_子女图鉴);
            子菜单_子女图鉴.get_text = pk::menu_item_get_text_t(getText_菜单_子女图鉴);
            子菜单_子女图鉴.get_desc = pk::menu_item_get_desc_t(getDesc_菜单_子女图鉴);
            //子菜单_子女图鉴.get_targets = cast<pk::unit_menu_item_get_targets_t@>(function() { return main.get_targets_arr_子女图鉴(); });
            子菜单_子女图鉴.handler = pk::menu_item_handler_t(handler_菜单_子女图鉴);
            // 子菜单_子女图鉴.handler = cast<pk::unit_menu_item_handler_t@>(function(dst_pos) { return main.handler_子女图鉴(dst_pos); });
            pk::add_menu_item(子菜单_子女图鉴);

            pk::menu_item 子菜单_他人妻妾图鉴;
            子菜单_他人妻妾图鉴.menu = 菜单_家族功能;
            子菜单_他人妻妾图鉴.shortcut = "-";
            子菜单_他人妻妾图鉴.is_visible = pk::menu_item_is_visible_t(isVisible_菜单_他人妻妾图鉴);
            子菜单_他人妻妾图鉴.is_enabled = pk::menu_item_is_enabled_t(isEnabled_菜单_他人妻妾图鉴);
            子菜单_他人妻妾图鉴.get_text = pk::menu_item_get_text_t(getText_菜单_他人妻妾图鉴);
            子菜单_他人妻妾图鉴.get_desc = pk::menu_item_get_desc_t(getDesc_菜单_他人妻妾图鉴);
            //子菜单_他人妻妾图鉴.get_targets = cast<pk::unit_menu_item_get_targets_t@>(function() { return main.get_targets_arr_他人妻妾图鉴(); });
            子菜单_他人妻妾图鉴.handler = pk::menu_item_handler_t(handler_菜单_他人妻妾图鉴);
            // 子菜单_他人妻妾图鉴.handler = cast<pk::unit_menu_item_handler_t@>(function(dst_pos) { return main.handler_他人妻妾图鉴(dst_pos); });
            pk::add_menu_item(子菜单_他人妻妾图鉴);

            pk::menu_item 子菜单_他人子女图鉴;
            子菜单_他人子女图鉴.menu = 菜单_家族功能;
            子菜单_他人子女图鉴.shortcut = "-";
            子菜单_他人子女图鉴.is_visible = pk::menu_item_is_visible_t(isVisible_菜单_他人子女图鉴);
            子菜单_他人子女图鉴.is_enabled = pk::menu_item_is_enabled_t(isEnabled_菜单_他人子女图鉴);
            子菜单_他人子女图鉴.get_text = pk::menu_item_get_text_t(getText_菜单_他人子女图鉴);
            子菜单_他人子女图鉴.get_desc = pk::menu_item_get_desc_t(getDesc_菜单_他人子女图鉴);
            //子菜单_他人子女图鉴.get_targets = cast<pk::unit_menu_item_get_targets_t@>(function() { return main.get_targets_arr_他人子女图鉴(); });
            子菜单_他人子女图鉴.handler = pk::menu_item_handler_t(handler_菜单_他人子女图鉴);
            // 子菜单_他人子女图鉴.handler = cast<pk::unit_menu_item_handler_t@>(function(dst_pos) { return main.handler_他人子女图鉴(dst_pos); });
            pk::add_menu_item(子菜单_他人子女图鉴);

           
        }

        // =============================================================================================

        void init_菜单_家族功能(pk::building @building)
        {
            @building_ = @building;
            @force_ = pk::get_force(building.get_force_id());
            @taishu_ = pk::get_person(pk::get_taishu_id(building));
            @kunshu_ = pk::get_person(force_.kunshu);

            if ((building_.get_id() <= 41) and (building_.get_id() >= 0))
                @city_ = pk::building_to_city(building);
            else if ((building_.get_id() <= 51) and (building_.get_id() >= 42))
                @gate_ = pk::building_to_gate(building);
            else if ((building_.get_id() <= 86) and (building_.get_id() >= 52))
                @port_ = pk::building_to_port(building);
        }

        bool isVisible_菜单_家族功能()
        {
            if (building_.get_id() >= 据点_末)
                return false;
            if (building_.get_force_id() != kunshu_.get_force_id())
                return false;
            return true;
        }

        string getText_菜单_家族功能()
        {
            return pk::encode("家族功能");
        }

        bool isEnabled_菜单_家族功能()
        {
           if (building_.get_id() >= 据点_末)
                return false;
            return true;
        }

        string getDesc_菜单_家族功能()
        {
            return "";
        }

        /////////////////---------------------------------------------------------
        //妻妾图鉴

        void init_菜单_妻妾图鉴(pk::building @building)
        {
            @building_ = @building;
            @force_ = pk::get_force(building.get_force_id());
            @taishu_ = pk::get_person(pk::get_taishu_id(building));
            @kunshu_ = pk::get_person(force_.kunshu);

            if ((building_.get_id() <= 41) and (building_.get_id() >= 0))
                @city_ = pk::building_to_city(building);
            else if ((building_.get_id() <= 51) and (building_.get_id() >= 42))
                @gate_ = pk::building_to_gate(building);
            else if ((building_.get_id() <= 86) and (building_.get_id() >= 52))
                @port_ = pk::building_to_port(building);
        }

        bool isVisible_菜单_妻妾图鉴()
        {
            if (building_.get_id() >= 据点_末)
                return false;
            if (building_.get_force_id() != kunshu_.get_force_id())
                return false;
            return true;
        }

        string getText_菜单_妻妾图鉴()
        {
            return pk::encode("妻妾图鉴");
        }

        bool isEnabled_菜单_妻妾图鉴()
        {
            if (building_.get_id() >= 据点_末)
                  return false;   
            return true;
        }

        string getDesc_菜单_妻妾图鉴()
        {
            return "";
        }
        
       bool handler_菜单_妻妾图鉴() 
        {
          // pk::dialog@ dialog = create_dlg();
           pk::dialog@ dialog = create_dlg_other(kunshu_,0);
           open_dlg(dialog);
           return true;
        }
       //
       // 
       // 
       //子女图鉴

       void init_菜单_子女图鉴(pk::building @building)
       {
           @building_ = @building;
           @force_ = pk::get_force(building.get_force_id());
           @taishu_ = pk::get_person(pk::get_taishu_id(building));
           @kunshu_ = pk::get_person(force_.kunshu);

           if ((building_.get_id() <= 41) and (building_.get_id() >= 0))
               @city_ = pk::building_to_city(building);
           else if ((building_.get_id() <= 51) and (building_.get_id() >= 42))
               @gate_ = pk::building_to_gate(building);
           else if ((building_.get_id() <= 86) and (building_.get_id() >= 52))
               @port_ = pk::building_to_port(building);
       }

       bool isVisible_菜单_子女图鉴()
       {
           if (building_.get_id() >= 据点_末)
               return false;
           if (building_.get_force_id() != kunshu_.get_force_id())
               return false;
           return true;
       }

       string getText_菜单_子女图鉴()
       {
           return pk::encode("子女图鉴");
       }

       bool isEnabled_菜单_子女图鉴()
       {
           if (building_.get_id() >= 据点_末)
               return false;
           return true;
       }

       string getDesc_菜单_子女图鉴()
       {
           return "";
       }

       bool handler_菜单_子女图鉴()
       {
           // pk::dialog@ dialog = create_dlg();
           pk::dialog@ dialog = create_dlg_other(kunshu_,1);
           open_dlg(dialog);
           return true;
       }
       //他人妻妾图鉴
       void init_菜单_他人妻妾图鉴(pk::building @building)
       {
           @building_ = @building;
           @force_ = pk::get_force(building.get_force_id());
           @taishu_ = pk::get_person(pk::get_taishu_id(building));
           @kunshu_ = pk::get_person(force_.kunshu);

           if ((building_.get_id() <= 41) and (building_.get_id() >= 0))
               @city_ = pk::building_to_city(building);
           else if ((building_.get_id() <= 51) and (building_.get_id() >= 42))
               @gate_ = pk::building_to_gate(building);
           else if ((building_.get_id() <= 86) and (building_.get_id() >= 52))
               @port_ = pk::building_to_port(building);
       }

       bool isVisible_菜单_他人妻妾图鉴()
       {
           if (building_.get_id() >= 据点_末)
               return false;
           if (building_.get_force_id() != kunshu_.get_force_id())
               return false;
           return true;
       }

       string getText_菜单_他人妻妾图鉴()
       {
           return pk::encode("他人妻妾图鉴");
       }

       bool isEnabled_菜单_他人妻妾图鉴()
       {
           if (building_.get_id() >= 据点_末)
               return false;
           return true;
       }

       string getDesc_菜单_他人妻妾图鉴()
       {
           return "";
       }

       bool handler_菜单_他人妻妾图鉴()
       {
           person_list = getTargetList();
           person_sel_arr = pk::person_selector(pk::encode("角色选择"), pk::encode("请选择要查看信息的武将."), person_list, 1, 1);
           if (person_sel_arr.count == 0)
               return true;
           @select_person = person_sel_arr[0];
           pk::dialog@ dialog = create_dlg_other(select_person,0);
           open_dlg(dialog);
           return true;
       }

       // 
    // 
    //他人子女图鉴

       void init_菜单_他人子女图鉴(pk::building @building)
       {
           @building_ = @building;
           @force_ = pk::get_force(building.get_force_id());
           @taishu_ = pk::get_person(pk::get_taishu_id(building));
           @kunshu_ = pk::get_person(force_.kunshu);

           if ((building_.get_id() <= 41) and (building_.get_id() >= 0))
               @city_ = pk::building_to_city(building);
           else if ((building_.get_id() <= 51) and (building_.get_id() >= 42))
               @gate_ = pk::building_to_gate(building);
           else if ((building_.get_id() <= 86) and (building_.get_id() >= 52))
               @port_ = pk::building_to_port(building);
       }

       bool isVisible_菜单_他人子女图鉴()
       {
           if (building_.get_id() >= 据点_末)
               return false;
           if (building_.get_force_id() != kunshu_.get_force_id())
               return false;
           return true;
       }

       string getText_菜单_他人子女图鉴()
       {
           return pk::encode("他人子女图鉴");
       }

       bool isEnabled_菜单_他人子女图鉴()
       {
           if (building_.get_id() >= 据点_末)
               return false;
           return true;
       }

       string getDesc_菜单_他人子女图鉴()
       {
           return "";
       }

       bool handler_菜单_他人子女图鉴()
       {
           person_list = getTargetList();
           person_sel_arr = pk::person_selector(pk::encode("角色选择"), pk::encode("请选择要查看信息的武将."), person_list, 1, 1);
           if (person_sel_arr.count == 0)
               return true;
           @select_person = person_sel_arr[0];
           pk::dialog@ dialog = create_dlg_other(select_person, 1);
           open_dlg(dialog);
           return true;
       }
      

       void open_dlg(pk::dialog@ dialog)
       {
           dialog.open();
           dialog.delete();
       }

       //他人妻妾图鉴窗口
       pk::dialog@ create_dlg_other(pk::person@ select_person,int 查看内容)
       {
           ///////////////////背景窗体///////////////////
           pk::dialog@ dialog = pk::new_dialog();
           pk::size dialog_size = pk::size(1360, 680);
           auto buttons = UI::create_dlg_320(dialog, dialog_size, pk::encode(框体标题[查看内容]));
           pk::button@ ok_button = buttons[0];
           pk::button@ esc_button = buttons[1];
           //创建主要内容框,并居中
           @taishu_autonomy_dialog = @dialog;
           //taishu_autonomy_dialog.set_size(1100,2000);
           dialog.set_pos(pk::get_resolution().width / 2 - dialog_size.width / 2, pk::get_resolution().height / 2 - dialog_size.height / 2 - 60);
           //dialog.set_size(dialog_size);
          // dialog.set_size(1100.650);
           //开关按钮
           pk::detail::funcref func0 = cast<pk::button_on_released_t@>(function(button) {
               main.taishu_autonomy_dialog.close(1);
           });
           ok_button.on_button_released(func0);
           func0 = cast<pk::button_on_released_t@>(function(button) {
               main.taishu_autonomy_dialog.close(1);
           });
           esc_button.on_button_released(func0);
           //~~~~~~~~~~~~~~~~~~~~
           pk::sprite9@ bgselectperson1 = taishu_autonomy_dialog.create_sprite9(375);
           bgselectperson1.set_pos(15, 285);
           bgselectperson1.set_size(110, 120);
           bgselectperson1.set_color(0xffFFD700);
           pk::sprite9@ bgselectperson = taishu_autonomy_dialog.create_sprite9(384);
           bgselectperson.set_pos(15, 257);
           bgselectperson.set_size(110, 30);
          // bgselectperson.set_color(0xffE6E6FA);
           string select_name = pk::get_name(select_person);
           pk::text@ select_name_text = taishu_autonomy_dialog.create_text();
           ///  string myqiqiename = pk::get_birthplace(2);
           select_name_text.set_text_font(FONT_BIG);
           select_name_text.set_text_color(0, 0xffffffff);
           select_name_text.set_text(select_name);
           select_name_text.set_pos(17, 257);
           select_name_text.set_size(80, 30);

           pk::face@ zhugong_face0 = draw_dialog_tool::draw_face(taishu_autonomy_dialog, { 100, 110 }, { 20, 290 }, select_person.face);//主公



           //ui,不动---
           pk::sprite0@ sp0 = taishu_autonomy_dialog.create_sprite0(428);
           sp0.set_size(30, 8);
           sp0.set_pos(20 + 110, 290 + 55);

           @ sp0 = taishu_autonomy_dialog.create_sprite0(428);
           sp0.set_size(30, 8);                                   // -----
           sp0.set_pos(20 + 30 + 110 + 6, 55 - 2);
           //  |

           pk::sprite0@ sp1 = taishu_autonomy_dialog.create_sprite0(435);// -|               //  |
           sp1.set_size(8, 640 + 30 + 12);                                 //  _____
           sp1.set_pos(20 + 110 + 30, 55);
           //------
           @ sp0 = taishu_autonomy_dialog.create_sprite0(428);
           sp0.set_size(30, 8);
           sp0.set_pos(20 + 30 + 110 + 6, 675 + 10 + 2 + 30 + 15);
           switch (查看内容)
           {
                case 0:perqiqie_list = getQiqieList(select_person); break;
                case 1:perqiqie_list = getErziList(select_person); break;
           }

           auto qiqie_list = pk::list_to_array(perqiqie_list);
           int imgnumber = qiqie_list.length;
           if (imgnumber > qiqie_max) imgnumber = qiqie_max; //最多显示21个妻妾
           array <pk::face@> qiqie_facex(imgnumber, null);
           array <pk::sprite9@> bgqizi(imgnumber, null);
           array <pk::sprite9@> bgqizi2(imgnumber, null);
           array <pk::sprite9@> bgqizi3(imgnumber, null);
           int 嫡子 = 0;
           int 嫡女 = 0;
           int 庶子 = 0;
           int 庶女 = 0;
           for (int i = 0; i < imgnumber; i++)
           {

               int x = 0;
               int y = 0;
               if (i < 7)
               {
                   x = 30 + 20 + 30 + 110 + i * 170;
                   y = 70;

               }
               if (i >= 7 && i < 14)
               {
                   x = 30 + 20 + 30 + 110 + (i - 7) * 170;
                   y = 290;
               }
               if (i >= 14)
               {
                   x = 30 + 20 + 30 + 110 + (i - 14) * 170;
                   y = 510;
               }

               @bgqizi2[i] = taishu_autonomy_dialog.create_sprite9(375);
               bgqizi2[i].set_pos(x - 25 + 20 - 5, y - 5);
               bgqizi2[i].set_size(160, 210);
               bgqizi2[i].set_color(0x33778899);

               @bgqizi[i] = taishu_autonomy_dialog.create_sprite9(375);
               bgqizi[i].set_pos(x - 25 + 20, y);
               bgqizi[i].set_size(150, 200);
               bgqizi[i].set_color(0x33778899);



               @bgqizi3[i] = taishu_autonomy_dialog.create_sprite9(375);
               bgqizi3[i].set_pos(x - 5, y + 110);
               bgqizi3[i].set_size(150, 90);
               bgqizi3[i].set_color(0x33778899);

               if (qiqie_list[i].get_id() == select_person.spouse)
               {
                   bgqizi2[i].set_color(0xffFFD700);//妻子金框
               }

               @qiqie_facex[i] = draw_dialog_tool::draw_face(taishu_autonomy_dialog, { 100, 110 }, { x - 25 + 20, y }, qiqie_list[i].face);
               //名字
               pk::text@ qiqie_name = taishu_autonomy_dialog.create_text();
               qiqie_name.set_pos(x + 95, y + 5);
               qiqie_name.set_size(60, 20);
               pk::person@ qiqie_getid = pk::get_person(qiqie_list[i].get_id());
               string myqiqiename = pk::get_name(qiqie_getid);
               ///  string myqiqiename = pk::get_birthplace(2);
               qiqie_name.set_text_font(FONT_SMALL);
               qiqie_name.set_text_color(0, 0xffADD8E6);
               qiqie_name.set_text(myqiqiename);

               pk::text@ qiqie_identity = taishu_autonomy_dialog.create_text();
               qiqie_identity.set_pos(x + 95, y + 25);
               qiqie_identity.set_size(60, 20);
               /* pk::person@ qiqie_getid = pk::get_person(qiqie_list[i].get_id());
                string myqiqieidentity = pk::get_identity(qiqie_getid);*/
               qiqie_identity.set_text_font(FONT_SMALL);
               qiqie_identity.set_text_color(0, 0xff32CD32);
               if (查看内容 == 0)
               {
                   if (qiqie_list[i].get_id() == select_person.spouse)
                   {
                       qiqie_identity.set_text(pk::encode("正妻"));
                   }
                   else
                   {
                       qiqie_identity.set_text(pk::encode("小妾"));
                   }
               }
               else if(查看内容 == 1)
               {
                   if (qiqie_list[i].sei == select_person.sei)//判断是否是亲子
                   {
                       //防止超出坐标
                       if (嫡子 > 4)
                           嫡子 = 4;
                       if (嫡女 > 4)
                           嫡女 = 4;
                       if (庶子 > 4)
                           庶子 = 4;
                       if (庶女 > 4)
                           庶女 = 4;

                       if (qiqie_list[i].mother == select_person.spouse)//判断是否是庶子
                       {
                          if (qiqie_list[i].sex == 0)
                          {
                             qiqie_identity.set_text(pk::encode(嫡子类型[嫡子]));
                             if(嫡子==0)
                                bgqizi2[i].set_color(0xffFFD700);
                             嫡子++;
                          }
                          else
                          {
                            qiqie_identity.set_text(pk::encode(嫡女类型[嫡女]));
                            if (嫡女 == 0)
                                bgqizi2[i].set_color(0xffFFD700);
                            嫡女++;
                          }
                       }
                       else
                       {
                           if (qiqie_list[i].sex == 0)
                           {
                               qiqie_identity.set_text(pk::encode(庶子类型[庶子]));
                               庶子++;
                           }
                           else
                           {
                               qiqie_identity.set_text(pk::encode(庶女类型[庶女]));
                               庶女++;
                           }
                       }
                   }
                   else
                   {
                       qiqie_identity.set_text(pk::encode("养子"));
                   }
               }
               pk::text@ qiqie_year = taishu_autonomy_dialog.create_text();
               qiqie_year.set_pos(x + 95, y + 45);
               qiqie_year.set_size(60, 20);
               qiqie_year.set_text_font(FONT_SMALL);
               qiqie_year.set_text_color(0, 0xffF08080);
               int qiqieyear_number = pk::get_year() - qiqie_list[i].birth;
               string yearstr = qiqieyear_number + "岁";
               if (qiqieyear_number <= 0)
               {
                   yearstr = "未出生";
               }
               /* pk::person@ qiqie_getid = pk::get_person(qiqie_list[i].get_id());
                string myqiqieyear = pk::get_year(qiqie_getid);*/
               qiqie_year.set_text(pk::encode(yearstr));

               //性格
               pk::text@ qiqie_character = taishu_autonomy_dialog.create_text();
               qiqie_character.set_pos(x + 95, y + 65);
               qiqie_character.set_size(60, 20);
               int character_no = qiqie_list[i].character;
               qiqie_character.set_text_font(FONT_SMALL);
               qiqie_character.set_text_color(0, 0xffFFEBCD);
               qiqie_character.set_text(pk::encode(性格[character_no]));

               //所属区域
               pk::text@ qiqie_birthplace = taishu_autonomy_dialog.create_text();
               qiqie_birthplace.set_pos(x + 95, y + 85);
               qiqie_birthplace.set_size(60, 20);
               int birthplace_no = qiqie_list[i].birthplace;
               qiqie_birthplace.set_text_font(FONT_SMALL);
               qiqie_birthplace.set_text_color(0, 0xffB8860B);
               qiqie_birthplace.set_text(pk::encode(出生地[birthplace_no]));


               //五维数值
               array<pk::text@> wwnumber(5, null);
               for (int wwn = 0; wwn < 5; wwn++)
               {
                   int wwx = 0;
                   int wwy = 0;

                   if (i < 7)
                   {
                       wwx = 30 + 25 + 30 + 110 + i * 170;
                       wwy = 70 + 120 + wwn * 18 - 12 + 1;

                   }
                   if (i >= 7 && i < 14)
                   {
                       wwx = 30 + 25 + 30 + 110 + (i - 7) * 170;
                       wwy = 290 + 120 + wwn * 18 - 12 + 1;
                   }
                   if (i >= 14)
                   {
                       wwx = 30 + 25 + 30 + 110 + (i - 14) * 170;
                       wwy = 510 + 120 + wwn * 18 - 12 + 1;
                   }

                   @wwnumber[wwn] = taishu_autonomy_dialog.create_text();
                   wwnumber[wwn].set_pos(wwx, wwy);
                   wwnumber[wwn].set_size(20, 20);
                   wwnumber[wwn].set_text(pk::encode(ww[wwn]));
                   wwnumber[wwn].set_text_font(FONT_SMALL);
                   wwnumber[wwn].set_text_color(0, statecolor[wwn]);

                   pk::text@ 妻子数值 = taishu_autonomy_dialog.create_text();
                   妻子数值.set_pos(wwx + 40 + 15, wwy + 9);
                   妻子数值.set_size(20, 2);
                   int 妻子数值数据 = qiqie_list[i].base_stat[wwn];
                   // int 妻子数值数据 = 99;
                   string 妻子数值数据2 = "" + 妻子数值数据;
                   妻子数值.set_text(pk::encode(string(妻子数值数据2)));
                   妻子数值.set_text_font(FONT_SMALL);
                   妻子数值.set_text_color(0, 0xffF8F8FF);


               }
               personinfo_moyu@ person_qiqie = @person_ex_moyu[qiqie_list[i].get_id()];
               int 标签数 = 0;
               //优先判定死亡
               if (pk::is_shibou(qiqie_list[i]) && qiqieyear_number > 16)
               {
                   pk::sprite9@ bgsiwang = taishu_autonomy_dialog.create_sprite9(375);
                   bgsiwang.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                   bgsiwang.set_size(25, 70);
                   bgsiwang.set_color(0xffE6E6FA);
                   for (int yqs = 0; yqs < 2; yqs++)
                   {
                       pk::text@ state_type = taishu_autonomy_dialog.create_text();
                       state_type.set_pos(x + 95 + 7 + 1, y + 90 + 20 + 15 + 5 + yqs * 30);
                       state_type.set_size(60, 20);
                       state_type.set_text(pk::encode(死亡[yqs]));
                       state_type.set_text_color(0, 0xffDC143C);
                       state_type.set_text_font(FONT_BIG);
                       qiqie_facex[i].set_color(0x1a808080);
                   }
                   标签数 = 标签数 + 10;
               }
               //是否是强娶来的
               if (查看内容 == 0)
               {
                   if (sheHaveHusband(qiqie_list[i], select_person.get_id()) && 标签数 == 0)
                   {
                       if (pk::is_alive(qiqie_list[i]) && person_qiqie.pregnancy > 0)//判断是否怀孕
                       {
                           pk::sprite9@ bgqiangqu = taishu_autonomy_dialog.create_sprite9(375);
                           bgqiangqu.set_pos(x + 95 + 7 - 12, y + 90 + 10 + 5 + 15);
                           bgqiangqu.set_size(25, 70);
                           bgqiangqu.set_color(0xffE6E6FA);

                           pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                           bghuaiyun.set_pos(x + 95 + 7 - 10 + 28, y + 90 + 10 + 5 + 15);
                           bghuaiyun.set_size(25, 70);
                           bghuaiyun.set_color(0xffE6E6FA);
                           for (int yqs = 0; yqs < 2; yqs++)
                           {
                               pk::text@ state_type = taishu_autonomy_dialog.create_text();
                               state_type.set_pos(x + 95 + 7 - 12 + 1, y + 90 + 20 + 15 + 5 + yqs * 30);
                               state_type.set_size(60, 20);
                               state_type.set_text(pk::encode(强娶[yqs]));
                               state_type.set_text_color(0, 0xffFF8C00);
                               state_type.set_text_font(FONT_BIG);

                               pk::text@ state_type2 = taishu_autonomy_dialog.create_text();
                               state_type2.set_pos(x + 95 + 7 - 10 + 28 + 1, y + 90 + 20 + 15 + 5 + yqs * 30);
                               state_type2.set_size(60, 20);
                               state_type2.set_text(pk::encode(怀孕[yqs]));
                               state_type2.set_text_color(0, 0xff32CD32);
                               state_type2.set_text_font(FONT_BIG);
                           }
                       }
                       else
                       {
                           pk::sprite9@ bgqiangqu = taishu_autonomy_dialog.create_sprite9(375);
                           bgqiangqu.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                           bgqiangqu.set_size(25, 70);
                           bgqiangqu.set_color(0xffE6E6FA);
                           for (int yqs = 0; yqs < 2; yqs++)
                           {
                               pk::text@ state_type = taishu_autonomy_dialog.create_text();
                               state_type.set_pos(x + 95 + 7 + 1, y + 90 + 20 + 15 + 5 + yqs * 30);
                               state_type.set_size(60, 20);
                               state_type.set_text(pk::encode(强娶[yqs]));
                               state_type.set_text_color(0, 0xffFF8C00);
                               state_type.set_text_font(FONT_BIG);;
                           }
                       }
                       标签数++;
                   }

                   //怀孕
                   if (pk::is_alive(qiqie_list[i]) && person_qiqie.pregnancy > 0 && 标签数 == 0)
                   {
                       pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                       bghuaiyun.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                       bghuaiyun.set_size(25, 70);
                       bghuaiyun.set_color(0xffE6E6FA);
                       for (int yqs = 0; yqs < 2; yqs++)
                       {
                           pk::text@ state_type = taishu_autonomy_dialog.create_text();
                           state_type.set_pos(x + 95 + 7 + 1, y + 90 + 20 + 15 + 5 + yqs * 30);
                           state_type.set_size(60, 20);
                           //string aa = 怀孕[yqs] + person_qiqie.pregnancy;用于测试怀孕状态的
                           state_type.set_text(pk::encode(怀孕[yqs]));
                           state_type.set_text_color(0, 0xff32CD32);
                           state_type.set_text_font(FONT_BIG);
                           //qiqie_facex[i].set_color(0xff32CD32);
                       }
                       标签数++;
                   }
               }
               else if (查看内容 == 1)
               {
                   //if (qiqieyear_number < 0&& 标签数 == 0)//未出生
                   //{
                   //    pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                   //    bghuaiyun.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                   //    bghuaiyun.set_size(25, 70);
                   //    bghuaiyun.set_color(0xffE6E6FA);
                   //    for (int yqs = 0; yqs < 3; yqs++)
                   //    {
                   //        pk::text@ state_type = taishu_autonomy_dialog.create_text();
                   //        state_type.set_pos(x + 95 + 7 + 1 + 5 - 2, y + 90 + 20 + 15 + 5 + yqs * 20 - 5);
                   //        state_type.set_size(60, 20);
                   //        //string aa = 怀孕[yqs] + person_qiqie.pregnancy;用于测试怀孕状态的
                   //        state_type.set_text(pk::encode(怀孕[yqs+2]));
                   //        state_type.set_text_color(0, 0xffFF8C00);
                   //        state_type.set_text_font(FONT_SMALL);
                   //        //qiqie_facex[i].set_color(0xff32CD32);
                   //    }
                   //    标签数++;
                   //}
                   if (qiqieyear_number <=1 && 标签数 == 0)
                   {
                       pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                       bghuaiyun.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                       bghuaiyun.set_size(25, 70);
                       bghuaiyun.set_color(0xffE6E6FA);
                       for (int yqs = 0; yqs < 3; yqs++)
                       {
                           pk::text@ state_type = taishu_autonomy_dialog.create_text();
                           state_type.set_pos(x + 95 + 7 + 1 + 5 - 2, y + 90 + 20 + 15 + 5 + yqs * 20 - 5);
                           state_type.set_size(60, 20);
                           //string aa = 怀孕[yqs] + person_qiqie.pregnancy;用于测试怀孕状态的
                           state_type.set_text(pk::encode(怀孕[yqs + 8]));//孕育中
                           state_type.set_text_color(0, 0xffFFB6C1);
                           state_type.set_text_font(FONT_SMALL);
                           //qiqie_facex[i].set_color(0xff32CD32);
                       }
                       标签数++;
                   }
                   else  if (select_person.get_id() == kunshu_.get_id()&&qiqieyear_number < 8&& qiqieyear_number > 0 && 标签数 == 0)
                   {
                       pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                       bghuaiyun.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                       bghuaiyun.set_size(25, 70);
                       bghuaiyun.set_color(0xffE6E6FA);
                       for (int yqs = 0; yqs < 3; yqs++)
                       {
                           pk::text@ state_type = taishu_autonomy_dialog.create_text();
                           state_type.set_pos(x + 95 + 7 + 1 + 5-2, y + 90 + 20 + 15 + 5 + yqs * 20-5);
                           state_type.set_size(60, 20);
                           //string aa = 怀孕[yqs] + person_qiqie.pregnancy;用于测试怀孕状态的
                           state_type.set_text(pk::encode(怀孕[yqs + 5]));//未出仕
                           state_type.set_text_color(0, 0xff32CD32);
                           state_type.set_text_font(FONT_SMALL);
                           //qiqie_facex[i].set_color(0xff32CD32);
                       }
                       标签数++;
                   }
                   else  if (select_person.get_id() != kunshu_.get_id() && qiqieyear_number < 12 && qiqieyear_number > 0 && 标签数 == 0)
                   {
                       pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                       bghuaiyun.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                       bghuaiyun.set_size(25, 70);
                       bghuaiyun.set_color(0xffE6E6FA);
                       for (int yqs = 0; yqs < 3; yqs++)
                       {
                           pk::text@ state_type = taishu_autonomy_dialog.create_text();
                           state_type.set_pos(x + 95 + 7 + 1 + 5 - 2, y + 90 + 20 + 15 + 5 + yqs * 20 - 5);
                           state_type.set_size(60, 20);
                           //string aa = 怀孕[yqs] + person_qiqie.pregnancy;用于测试怀孕状态的
                           state_type.set_text(pk::encode(怀孕[yqs + 5]));//未出仕
                           state_type.set_text_color(0, 0xff32CD32);
                           state_type.set_text_font(FONT_SMALL);
                           //qiqie_facex[i].set_color(0xff32CD32);
                       }
                       标签数++;
                   }
                   else
                   {
                       if (标签数 <= 0)
                       {
                           pk::sprite9@ bghuaiyun = taishu_autonomy_dialog.create_sprite9(375);
                           bghuaiyun.set_pos(x + 95 + 7, y + 90 + 10 + 5 + 15);
                           bghuaiyun.set_size(25, 70);
                           bghuaiyun.set_color(0xffE6E6FA);
                           for (int yqs = 0; yqs < 3; yqs++)
                           {
                               pk::text@ state_type = taishu_autonomy_dialog.create_text();
                               state_type.set_pos(x + 95 + 7 + 1 + 5 - 2, y + 90 + 20 + 15 + 5 + yqs * 20 - 5);
                               state_type.set_size(60, 20);
                               //string aa = 怀孕[yqs] + person_qiqie.pregnancy;用于测试怀孕状态的
                               state_type.set_text(pk::encode(怀孕[yqs + 11]));//已登场
                               state_type.set_text_color(0, 0xff48D1CC);
                               state_type.set_text_font(FONT_SMALL);
                               //qiqie_facex[i].set_color(0xff32CD32);
                           }
                           标签数++;
                       }
                   }

               }





               // @qiqiespouse_facex[i] = draw_dialog_tool::draw_face(taishu_autonomy_dialog, { 33, 36 }, { x+8+20, y+55-36 }, qiqie_list[i].spouse);
           }
           //ui
           pk::sprite9@ bg0 = taishu_autonomy_dialog.create_sprite9(384);
           bg0.set_pos(20 + 110, 60);
           bg0.set_size(30, 120);
           //妻妾图表4个字ui
           array<pk::text@> txtzs(4, null);
           for (int zslbi = 0; zslbi < 4; zslbi++)
           {

               int x = 110 + 6 + 18;
               int y = 36 + zslbi * 25 + 36;
               @txtzs[zslbi] = taishu_autonomy_dialog.create_text();
               txtzs[zslbi].set_pos(x, y);
               txtzs[zslbi].set_size(20, 20);
               if (查看内容 == 0) {
                   txtzs[zslbi].set_text(pk::encode(zslb[zslbi]));
               }
               else if (查看内容 == 1)
               {
                   txtzs[zslbi].set_text(pk::encode(zslb[zslbi+4]));
               }
               txtzs[zslbi].set_text_font(FONT_BIG);
           }

           return dialog;
       }

       /////
       bool sheHaveHusband(pk::person@ qiqie, int kunshu_id)//所娶的家族与人际是否有原配
       {
           int qiqie_id = qiqie.get_id();
           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               if (person.spouse == qiqie_id && i != kunshu_id)
                   return true;
           }
           return false;
       }///
       pk::list<pk::person@> getTargetList() //只要男性的列表
       {
           pk::list<pk::person@> list;
           int kunshu_0 = kunshu_.get_id();
           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               if (person.sex == 0 && person.get_id() != kunshu_0 && (!pk::is_bandit(person)) && (!pk::is_iminzoku(person)) && pk::is_alive(person) &&person.mibun!=-1 && person.mibun != 6 && person.mibun != 7)
                   list.add(person);

           }
           return list;
       }
       //儿子列表
       pk::list<pk::person@> getErziList(pk::person@ thefather)
       {
           pk::list<pk::person@> list_dz;
           pk::list<pk::person@> list_sz;
           pk::list<pk::person@> list_yz;
           int kunshu_0 = thefather.get_id();

           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               int qiqieyear_number = pk::get_year() - person.birth + 1;
               if ( person.father == kunshu_0 && thefather.sei == person.sei&&qiqieyear_number>=0 && person.mother == thefather.spouse)//嫡子
               {
                   list_dz.add(person);
               }
               //pk::person@ person = pk::get_person(i);

           }
           list_dz.sort(function(a, b)
           {
               return a.birth < b.birth;// 按年龄排序
           });
           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               int qiqieyear_number = pk::get_year() - person.birth + 1;
               if (person.father == kunshu_0 && thefather.sei == person.sei && qiqieyear_number >= 0 && person.mother != thefather.spouse)//庶子
               {
                   list_sz.add(person);
               }
               //pk::person@ person = pk::get_person(i);

           }
           list_sz.sort(function(a, b)
           {
               return a.birth < b.birth;// 按年龄排序
           });
           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               int qiqieyear_number = pk::get_year() - person.birth + 1;
               if (person.father == kunshu_0 && thefather.sei != person.sei && qiqieyear_number >= 0)//养子
               {
                   list_yz.add(person);
               }
               //pk::person@ person = pk::get_person(i);
           }
           list_yz.sort(function(a, b)
           {
               return a.birth < b.birth;// 按年龄排序
           });
           auto sz_list = pk::list_to_array(list_sz);
           int imgnumber_sz = sz_list.length;
           auto yz_list = pk::list_to_array(list_yz);
           int imgnumber_yz = yz_list.length;
           for (int i = 0; i < imgnumber_sz; i++)
           {
               list_dz.add(sz_list[i]);
           }
           for (int i = 0; i < imgnumber_yz; i++)
           {
               list_dz.add(yz_list[i]);
           }
           return list_dz;
       }

       //妻妾列表
       pk::list<pk::person@> getQiqieList(pk::person@ thefather)
       {
           pk::list<pk::person@> list;
           int kunshu_0 = thefather.get_id();
           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               if (person.spouse == kunshu_0 && thefather.spouse == person.get_id())//妻子
               {
                   list.add(person);
               }
               else continue;
           }
           for (int i = 0; i < 武将_末; i++)
           {
               pk::person@ person = pk::get_person(i);
               if (person.spouse == kunshu_0 && thefather.spouse != person.get_id())//小妾
               {
                   list.add(person);
               }
               else continue;
           }
           return list;
       }
       //

    }

    Main main;
}
